#include <iostream>
#include <string>

#include "bm_openssl.h"
#include "bm_base64.h"

using namespace std;
int main(int argc,char *argv[])
{
    cout << "main" << endl;
    // auto b64 = "WNnJJAx2Oh/nWQsZYo71fBzYkZX0FPEJldqs2OM6pSSuMJYTM/+4X2Fc91EyH3yqU7V0hugc6xXSrzMU6ntYGWJ+AEcoIK20rTIibYeyMPg=";
    auto b64 = "WNnJJAx2Oh/nWQsZYo71fBzYkZX0FPEJldqs2OM6pSSuMJYTM/+4X2Fc91EyH3yqU7V0hugc6xXSrzMU6ntYGWJ+AEcoIK20rTIibYeyMPg=";
    std::string bd64, to;
    bd64 = bm::base64_decode(b64);
    cout << "bd64 len:" << bd64.length() << endl;

    int r = bm::decrypt_aes_cbc(bd64, to, "yangfeizhinengszyangfeizhinengsz");

    cout << "r:" << r << " to len:" << to.length() << "," << to << endl;

    std::string src = R"({"method":"register","id":100,"sn":"OPENCV001","timestamp":1632736156})";
    to.clear();
    bd64.clear();
    r = bm::encrypt_aes_cbc(src, to, "yangfeizhinengszyangfeizhinengsz");
    bd64 = bm::base64_encode(to);
    cout << "bd64:" << bd64 << endl;
    return 0;
}